<link rel="stylesheet" href="__CDN__/assets/element-ui-2.15.14/css/index.css">
<link rel="stylesheet" href="__CDN__/assets/css/vvv.css">
<style>
    .el-form-item__label {
        width: 120px !important;
    }

    .el-tag + .el-tag {
        margin-left: 10px;
    }

    .button-new-tag {
        margin-left: 10px;
        height: 32px;
        line-height: 30px;
        padding-top: 0;
        padding-bottom: 0;
    }

    .input-new-tag {
        width: 90px;
        margin-left: 10px;
        vertical-align: bottom;
    }

    input[type="file"] {
        display: none !important;
    }

    .el-form-item__error {
        /*margin-left: 30px;*/
    }

    .search-select .el-input--suffix .el-input__inner {
        width: 130px;
    }

    .goods-detail-table {
        border: 1px solid #E6E6E6;
        border-bottom: none;
        margin-bottom: 20px;
    }

    .goods-detail-item {
        border-bottom: 1px solid #E6E6E6;
    }

    .goods-detail-item>div {
        padding: 5px 10px;
    }

    .goods-detail-name {
        width: 120px;
    }

    .goods-detail-msg {
        width: 378px;
    }

    .goods-detail-del,
    .goods-detail-move {
        width: 50px;
        display: flex;
        justify-content: center;
    }

    .goods-detail-del-icon {
        color: #ff5959;
    }

    .del-image-btn {
        position: absolute;
        width: 14px;
        height: 14px;
        line-height: 14px;
        text-align: center;
        border-radius: 50%;
        font-size: 12px;
        font-weight: 600;
        background: #7438D5;
        color: #fff;
        top: -7px;
        right: -7px;
    }
</style>
<div id="vue" v-cloak>
    <div class="screen-container">
        <div class="screen-container-show">
            <el-button style="margin-top: 14px;" size="small" @click="refreshPage" icon="el-icon-refresh" circle
                       type="primary"></el-button>
            <div class="screen-container-left display-flex">
                <div class="datetime">
                    <el-date-picker
                            v-model="search.startTime"
                            type="datetime"
                            placeholder="选择起始时间">
                    </el-date-picker>
                </div>
                <div class="datetime">
                    <el-date-picker
                            v-model="search.endTime"
                            type="datetime"
                            placeholder="选择结束时间">
                    </el-date-picker>
                </div>
            </div>
            <div class="search-select screen-container-right display-flex keyword">
                <el-select v-model="search.status" @clear="handleClearSelect('status')" clearable placeholder="启用状态">
                    <el-option
                            v-for="item in statusOpt"
                            :key="item.id"
                            :label="item.value"
                            :value="item.id">
                    </el-option>
                </el-select>
            </div>
            <div class="search-select screen-container-right display-flex keyword v-key">
                <el-input @clear="handleClearSearchInp" clearable v-model="search.keyword" placeholder="请输入您要搜索的内容">
                    <el-select v-model="search.type" slot="prepend" placeholder="请选择">
                        <el-option v-for="(item, index) in searchOpt" :label="item.value"
                                   :value="item.id">
                        </el-option>
                    </el-select>
                    <el-button slot="append" @click="searchData" icon="el-icon-search"></el-button>
                </el-input>
            </div>
            <div class="search-select screen-container-right display-flex keyword">
                <el-button @click="openAddDialog('add', '')" size="small" type="primary" plain icon="el-icon-plus">添加
                </el-button>
                <el-button @click="del" size="small" type="danger" plain icon="el-icon-delete">删除
                </el-button>
            </div>
        </div>
    </div>
    <div class="vue-table background-white color-666">
        <el-table :data="tableData" border highlight-current-row v-loading="listLoading"
                  @sort-change="sortChange" :element-loading-text="loadingText"
                  @selection-change="handleSelectionChange" style="width: 100%">
            <el-table-column type="selection" width="60" align="center"></el-table-column>
            <el-table-column prop="title" label="标题" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="status" width="150" label="状态" show-overflow-tooltip
                             align="center">
                <template scope="scope">
                    <el-switch
                            :active-value="1"
                            :inactive-value="2"
                            v-model="scope.row.status"
                            @change="statusChange(scope.row)"
                    >
                    </el-switch>
                </template>
            </el-table-column>
            <el-table-column prop="create_time" width="160" :formatter="dateFormat" label="创建时间" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column align="center" width="320" fixed="right" label="操作">
                <template scope="scope">
                    <button @click="openAddDialog('edit', scope.row)" type="button"
                            class="el-button el-button--primary el-button--small"><i
                            class="el-icon-edit"></i><span>编辑</span></button>
                    <button @click="handleCopy(scope.row.id)" type="button"
                            class="el-button el-button--success el-button--small"><i
                            class="el-icon-document-copy"></i><span>复制</span></button>
                    <button @click="dell(scope.row.id)" type="button"
                            class="el-button el-button--danger el-button--small"><i
                            class="el-icon-delete"></i><span>删除</span></button>
                </template>
            </el-table-column>
        </el-table>
        <div class="layout-pagination">
            <el-pagination
                    background
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[10, 20, 50, 100]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="totalCount">
            </el-pagination>
        </div>
    </div>

    <!-- 添加编辑 -->
    <div class="users-dialog">
        <el-dialog
                :close-on-click-modal="false"
                :title="title"
                :visible.sync="addDialog"
                width="75%"
        >
            <div class="form">
                <el-form ref="form" :rules="rules" :model="formData" label-width="120px">
                    <el-form-item label="标题：" prop="title">
                        <el-input placeholder="请您输入标题" style="width: 330px;" maxlength="50" show-word-limit
                                  v-model="formData.title"></el-input>
                    </el-form-item>
                    <el-form-item label="参数详情：">
                        <div>
                            <div class="goods-detail-table">
                                <div class="display-flex goods-detail-item">
                                    <div class="goods-detail-name">
                                        参数名称
                                    </div>
                                    <div class="goods-detail-msg">
                                        内容
                                    </div>
                                    <div class="goods-detail-del">
                                        删除
                                    </div>
                                    <div class="goods-detail-move">
                                        移动
                                    </div>
                                </div>
                                <draggable :list="formData.params" v-bind="$attrs" :options="{animation: 500}">
                                    <div class="display-flex goods-detail-item"
                                         v-for="(it, index) in formData.params">
                                        <div class="goods-detail-name">
                                            <el-input type="input" v-model="it.title" style="width:90px" size="small">
                                            </el-input>
                                        </div>
                                        <div class="goods-detail-msg">
                                            <el-input type="input" v-model="it.content" style="width:348px"
                                                      size="small">
                                            </el-input>
                                        </div>
                                        <div class="goods-detail-del">
                                            <div style="cursor: pointer;" class="goods-detail-del-icon" @click="delParams(index)">
                                                删除
                                            </div>
                                        </div>
                                        <div style="cursor: move;" class="goods-detail-move">
                                            <img src="/assets/addons/shopro/img/goods/move.png">
                                        </div>
                                    </div>
                                </draggable>
                            </div>
                            <div class="btn-common add-params">
                                <el-button type="primary" size="small" @click="addParams" icon="el-icon-plus">添加参数</el-button>
                            </div>
                        </div>
                    </el-form-item>
                    <el-form-item label="状态：" prop="status">
                        <el-radio style="margin-right: 0;" v-model="formData.status" label="1" border size="small">显示
                        </el-radio>
                        <el-radio v-model="formData.status" label="2" border size="small">隐藏</el-radio>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addDialog = false" size="small" icon="el-icon-switch-button">取 消</el-button>
                <el-button type="primary" size="small" @click="submit" icon="el-icon-position">提 交</el-button>
            </span>
        </el-dialog>
    </div>
</div>

<script src="__CDN__/assets/element-ui-2.15.14/js/vue.js"></script>
<script src="__CDN__/assets/element-ui-2.15.14/js/index.js"></script>
<script src="__CDN__/assets/addons/shopro/libs/Sortable.min.js"></script>
<script src="__CDN__/assets/addons/shopro/libs/vuedraggable.js"></script>
<script src="__CDN__/assets/tool/libs/moment.js"></script>
<script src="__CDN__/assets/js/jquery-2.1.1.min.js"></script>